package it.polimi.TravelDream.ejb.entities;

import it.polimi.TravelDream.ejb.dtos.HotelDTO;
import it.polimi.TravelDream.ejb.entities.Address;

import java.io.Serializable;
import java.lang.String;
import java.util.List;

import javax.persistence.*;

import org.hibernate.validator.constraints.NotEmpty;

/**
 * Entity implementation class for Entity: Hotel
 *
 */
@Entity
@Table(name = "hotels")
@NamedQueries({
    @NamedQuery(name = Hotel.FIND_HOTELS_BY_NAME_AND_CITY, query = "SELECT h FROM Hotel h WHERE h.name = :name and h.hotelAddress.city = :city"),
    @NamedQuery(name = Hotel.FIND_HOTELS_BY_PARTIAL_NAME, query = "SELECT h FROM Hotel h WHERE h.name LIKE :nameHotel"),
    @NamedQuery(name = Hotel.FIND_HOTELS_NAME_BY_CITY, query = "SELECT h.name FROM Hotel h WHERE h.hotelAddress.city = :city "),
    @NamedQuery(name = Hotel.FIND_ALL_HOTEL, query = "SELECT h FROM Hotel h"),
    @NamedQuery(name = Hotel.FIND_CITIES_OF_HOTELS, query = "Select DISTINCT h.hotelAddress.city from Hotel h"),
    @NamedQuery(name = Hotel.FIND_BY_HOTELID, query = "Select h FROM Hotel h WHERE h.hotelID = :hotelID")
})
public class Hotel implements Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int hotelID;
	@Column(length = 30)
	@NotEmpty
	private String name;
	private int stars;
	
	@OneToOne
	@JoinColumn(name = "addresses_addressID")
	private Address hotelAddress;

	@OneToMany(mappedBy = "hotelName")
	private List <Room> list_of_room;
	
	private static final long serialVersionUID = 1L;
	
	public static final String FIND_HOTELS_BY_NAME_AND_CITY = "Hotel.findHotelsByNameAndCity";
	public static final String FIND_HOTELS_BY_PARTIAL_NAME = "Hotel.findHotelsByPartialName";
	public static final String FIND_HOTELS_NAME_BY_CITY = "Hotel.findHotelsNameByCity";
	public static final String FIND_ALL_HOTEL = "Hotel.findAllHotel";
	public static final String FIND_CITIES_OF_HOTELS = "Hotel.findCitiesFromHotels";
	public static final String FIND_BY_HOTELID = "Hotel.findByHotelID";
	public static final String FIND_ROOM_LIST ="Hotel.findRoomList";

	public Hotel() {
	}   
	
	public Hotel(HotelDTO hotelDTO, Address address) {
		super();
		this.name = hotelDTO.getName();
		this.stars = hotelDTO.getStars();
		this.hotelAddress = address;
	} 
	
	public int getHotelID() {
		return this.hotelID;
	}

	public void setHotelID(int hotelID) {
		this.hotelID = hotelID;
	}   
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}   
	public int getStars() {
		return this.stars;
	}

	public void setStars(int stars) {
		this.stars = stars;
	}   
	public Address getHotelAddress() {
		return this.hotelAddress;
	}

	public void setHotelAddress(Address hotelAddress) {
		this.hotelAddress = hotelAddress;
	}

	public List<Room> getList_of_room() {
		return list_of_room;
	}

	public void setList_of_room(List<Room> list_of_room) {
		this.list_of_room = list_of_room;
	}

   
}
